<?php

namespace App\Http\Requests\Company\Job;
use App\Http\Requests\Request;

class AddJobRequest extends Request {
    public function authorize(){
        return true;
    }
    public function rules(){

        if($this->contact_info == '2'){
            return [
                'job_title'=>'required',
                'industry'=>'required',
                'job_category1'=>'required',
                'location1'=>'required',
                'recruiting_num'=>'integer',
                'salary_above' => 'required|check_salary:'.$this->salary_below,
                'salary_below' => 'required',
                'welfare' => 'required',
                'age_above' => 'check_age:'.$this->age_below,
                'contacts'=>'required',
                'phone'=>'check_company_phone',
                'fax'=>'check_fax',
                'email'=>'email',
            ];
        }else{
            return [
                'job_title'=>'required',
                'industry'=>'required',
                'job_category1'=>'required',
                'location1'=>'required',
                'recruiting_num'=>'integer',
                'salary_above' => 'required|check_salary:'.$this->salary_below,
                'salary_below' => 'required',
                'welfare' => 'required',
                'age_above' => 'check_age:'.$this->age_below,
            ];
        }
    }
    public function messages(){
        return [
            'job_title.required'=>'职位名称不能为空',
            'industry.required'=>'请选择所属行业',
            'job_category1.required'=>'请选择岗位类别',
            'location1.required'=>'请选择工作地区',
            'recruiting_num.integer'=>'招聘人数只能为整数(0代表若干)',
            'salary_above.required'=>'请选择开始薪资',
            'salary_above.check_salary'=>'开始薪资必须大于结束薪资',
            'salary_below.required'=>'请选择结束薪资',
            'welfare.required'=>'请选择职位诱惑',
            'age_above.check_age'=>'开始年龄必须大于结束年龄',
            'contacts.required'=>'联系人不能为空',
            'phone.check_company_phone'=>'请输入正确的电话号码',
            'fax.check_fax'=>'请输入正确的传真号码',
            'email.email'=>'请输入正确的邮箱地址',
        ];
    }
}